#include "database.h"

Database::Database(QObject* parent) :
    QObject(parent)
{
    db = QSqlDatabase::addDatabase("QSQLITE");
}

void Database::setDatabase(QString dbName)
{
    db.setDatabaseName(dbName);
}

void Database::repareDB
{
    db.open();    
} 

void Database::setTable(QString tableName)
{
    table = tableName;
} 

void Database::where(QString whereString)
{
    where = whereString;
}

void Database::SelectAll()
{
    query.exec("SELECT * FROM "+table+" "+where);
}

void Database::Select(QString select)
{
    query.exec("SELECT "+select+" FROM "+table+" "+where);
}

void Database::insert(QString *, QString *)
{
    
}

void Database::update(QString field, QString value)
{
    query.exec("UPDATE "+table+" SET "+field" = "+value+where);
}

void Database::getResult()
{
    
}
